package o;

import android.app.Activity;
import android.content.Context;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appgallery.share.bean.AppKeyInfo;
import com.huawei.appgallery.share.bean.AppKeyListResBean;

public class cwq {

    public interface e {
        void ˊ(Context context);

        void ˎ(Context context);

        void ˎ(Context context, String str, String str2);

        void ˏ(Context context);
    }

    class a implements IServerCallBack {
        final /* synthetic */ cwq ˊ;
        private String ˎ;
        private Context ˏ;
        private e ॱ;

        public a(cwq o_cwq, Context context, String str, e eVar) {
            this.ˊ = o_cwq;
            this.ˎ = str;
            this.ॱ = eVar;
            this.ˏ = context;
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            AppKeyListResBean appKeyListResBean = (AppKeyListResBean) responseBean;
            if (appKeyListResBean.getResponseCode() != 0) {
                if (appKeyListResBean.getResponseCode() == 3) {
                    this.ॱ.ˎ(this.ˏ);
                } else {
                    this.ॱ.ˏ(this.ˏ);
                }
            } else if (CollectCheck.isEmpty(appKeyListResBean.list_)) {
                this.ॱ.ˊ(this.ˏ);
            } else {
                AppKeyInfo appKeyInfo = (AppKeyInfo) appKeyListResBean.list_.get(0);
                if (appKeyInfo == null || dof.ˋ(appKeyInfo.ˊ())) {
                    this.ॱ.ˊ(this.ˏ);
                    return;
                }
                String ˊ = appKeyInfo.ˊ();
                if (dof.ˋ(ˊ)) {
                    this.ॱ.ˊ(this.ˏ);
                    return;
                }
                this.ˊ.ˊ(this.ˎ, appKeyInfo.ˊ());
                this.ॱ.ˎ(this.ˏ, this.ˎ, ˊ);
            }
        }
    }

    public void ॱ(Context context, String str, e eVar) {
        if (eVar == null) {
            throw new NullPointerException("keyLoadedListener can not be null!");
        }
        AppKeyInfo ˎ = ˎ(str);
        if (dof.ˋ(ˎ.ˊ())) {
            IServerCallBack aVar = new a(this, context, str, eVar);
            cvt o_cxb = new cxb(str);
            if (context instanceof Activity) {
                o_cxb.setServiceType_(dgm.ˎ((Activity) context));
            }
            cfw.ˎ(o_cxb, aVar);
            return;
        }
        String ˊ = ˎ.ˊ();
        if (dof.ˋ(ˊ)) {
            cfw.ˎ(new cxb(str), new a(this, context, str, eVar));
            return;
        }
        eVar.ˎ(context, str, ˊ);
    }

    private AppKeyInfo ˎ(String str) {
        AppKeyInfo appKeyInfo = new AppKeyInfo();
        appKeyInfo.ˋ(new eui("PluginInfoNew").ˊ(str + ".secretKey" + "1", null));
        return appKeyInfo;
    }

    private void ˊ(String str, String str2) {
        new eui("PluginInfoNew").ˏ(str + ".secretKey" + "1", str2);
    }
}
